import { defineConfig } from 'vite'
import requireTransform from 'vite-plugin-require-transform'
import vue from '@vitejs/plugin-vue'
const { resolve } = require('path')

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    requireTransform({
      fileRegex: /.ts$|.tsx$|.vue$/
      //   fileRegex:/.js$|.jsx$|.vue$/
    })
  ],
  open: true,
  resolve: {
    alias: {
      '@components': resolve(__dirname, 'src/components'),
      '@utils': resolve(__dirname, 'src/utils'),
      '@api': resolve(__dirname, 'src/api'),
      '@': resolve(__dirname, 'src')
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "@/assets/css/mixin.scss";`
      }
    }
  },
  server: {
    port: '7010'
  },
  base: '/',
  build: {
    minify: 'terser',
    terserOptions: {
      compress: {
        //生产环境时移除console
        drop_console: true,
        drop_debugger: true
      }
    },
    outDir: './old-book-back'
  }
})
